package com.viphuli.app.tool.handler;


import java.util.Date;


import com.offroader.utils.DateUtils;
import com.viphuli.app.tool.R;
import com.viphuli.app.tool.bean.page.ArrangeTypePage;
import com.viphuli.app.tool.bean.part.ArrangeType;
import com.viphuli.app.tool.fragment.ArrangeTypeEditFragment;

public class ArrangeTypeInfoResponseHandler extends MyBaseHttpResponseHandler<ArrangeTypeEditFragment, ArrangeTypePage> {

	@Override
	public void deal() {

		ArrangeType arrangeTypeInfo = page.getArrangeTypeInfo();
		String starTime = DateUtils.formatHM(new Date(arrangeTypeInfo.getStart()*1000));
		String endTime = DateUtils.formatHM(new Date(arrangeTypeInfo.getEnd()*1000));
		
		caller.setArrangeTypeInfo(arrangeTypeInfo);
		
		caller.getName().setText(arrangeTypeInfo.getName());
		caller.getStart().setText(starTime);
		caller.getEnd().setText(endTime);
		
		caller.setStartTime(arrangeTypeInfo.getStart()*1000);
		caller.setEndTime(arrangeTypeInfo.getEnd()*1000);
		caller.setCheckColor(arrangeTypeInfo.getColor());

		String color1 = caller.getResources().getString(R.color.cl_home_item_arrange_type_color_1);
		String color2 = caller.getResources().getString(R.color.cl_home_item_arrange_type_color_2);
		String color3 = caller.getResources().getString(R.color.cl_home_item_arrange_type_color_3);
		String color4 = caller.getResources().getString(R.color.cl_home_item_arrange_type_color_4);
		
		String color = arrangeTypeInfo.getColor();
		color = color.substring(1, color.length()-1).toLowerCase();//截取并转小写
		
		if (color1.contains(color)) {

			caller.getColorTab().check(R.id.id_home_item_arrange_type_color_1);

		} else if (color2.contains(color)) {

			caller.getColorTab().check(R.id.id_home_item_arrange_type_color_2);

		} else if (color3.contains(color)) {

			caller.getColorTab().check(R.id.id_home_item_arrange_type_color_3);

		} else if (color4.contains(color)) {

			caller.getColorTab().check(R.id.id_home_item_arrange_type_color_4);

		}

	}

}
